package com.fire.controller;


import com.fire.exception.ServiceException;
import com.fire.model.entity.Admin;
import com.fire.model.entity.Notice;
import com.fire.response.ResultData;
import com.fire.service.IAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-04-06
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@Api(tags = {"登录模块"})
@RequestMapping("/login")
public class LoginController {

    private final IAdminService adminService;

    /**
     * 管理员登录
     * @return
     */
    @PostMapping("/admin")
    @ApiOperation(value = "管理员登录")
    public ResultData doLogin(@RequestBody @Valid Admin admin) throws ServiceException {
        log.info("管理员登录请求.....");
        String token = adminService.login(admin);
        log.info("管理员登录请求成功...");
        return ResultData.success(token);
    }
}
